#include <stdio.h>
#include <string.h>

char *get_memory()
{
	char p[] = "xiaozhi";
	
	return p;	// warning: function returns address of locall variable
}

int main()
{
	char *str = NULL;
	
	str = get_memory();		// blank
	
	printf("%s\n", str);	
}

#if 0
/*
 * intel
 */
0000000000001169 <get_memory>:
    1169:	f3 0f 1e fa          	endbr64 
    116d:	55                   	push   %rbp
    116e:	48 89 e5             	mov    %rsp,%rbp
    1171:	48 83 ec 10          	sub    $0x10,%rsp
    1175:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
    117c:	00 00 
    117e:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
    1182:	31 c0                	xor    %eax,%eax
    1184:	48 b8 78 69 61 6f 7a 	movabs $0x69687a6f616978,%rax
    118b:	68 69 00 
    118e:	48 89 45 f0          	mov    %rax,-0x10(%rbp)
    1192:	b8 00 00 00 00       	mov    $0x0,%eax
    1197:	48 8b 55 f8          	mov    -0x8(%rbp),%rdx
    119b:	64 48 33 14 25 28 00 	xor    %fs:0x28,%rdx
    11a2:	00 00 
    11a4:	74 05                	je     11ab <get_memory+0x42>
    11a6:	e8 c5 fe ff ff       	callq  1070 <__stack_chk_fail@plt>
    11ab:	c9                   	leaveq 
    11ac:	c3                   	retq   

00000000000011ad <main>:
    11ad:	f3 0f 1e fa          	endbr64 
    11b1:	55                   	push   %rbp
    11b2:	48 89 e5             	mov    %rsp,%rbp
    11b5:	48 83 ec 10          	sub    $0x10,%rsp
    11b9:	48 c7 45 f8 00 00 00 	movq   $0x0,-0x8(%rbp)
    11c0:	00 
    11c1:	b8 00 00 00 00       	mov    $0x0,%eax
    11c6:	e8 9e ff ff ff       	callq  1169 <get_memory>
    11cb:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
    11cf:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    11d3:	48 89 c7             	mov    %rax,%rdi
    11d6:	e8 85 fe ff ff       	callq  1060 <puts@plt>
    11db:	b8 00 00 00 00       	mov    $0x0,%eax
    11e0:	c9                   	leaveq 
    11e1:	c3                   	retq   
    11e2:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
    11e9:	00 00 00 
    11ec:	0f 1f 40 00          	nopl   0x0(%rax)


/*
 * arm
 */
00000000004005fc <get_memory>:
  4005fc:	d10043ff 	sub	sp, sp, #0x10
  400600:	90000000 	adrp	x0, 400000 <_init-0x480>
  400604:	911be000 	add	x0, x0, #0x6f8
  400608:	f9400000 	ldr	x0, [x0]
  40060c:	f90007e0 	str	x0, [sp, #8]
  400610:	d2800000 	mov	x0, #0x0                   	// #0
  400614:	910043ff 	add	sp, sp, #0x10
  400618:	d65f03c0 	ret

000000000040061c <main>:
  40061c:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  400620:	910003fd 	mov	x29, sp
  400624:	f9000fbf 	str	xzr, [x29, #24]
  400628:	97fffff5 	bl	4005fc <get_memory>
  40062c:	f9000fa0 	str	x0, [x29, #24]
  400630:	f9400fa0 	ldr	x0, [x29, #24]
  400634:	97ffffaf 	bl	4004f0 <puts@plt>
  400638:	52800000 	mov	w0, #0x0                   	// #0
  40063c:	a8c27bfd 	ldp	x29, x30, [sp], #32
  400640:	d65f03c0 	ret
  400644:	00000000 	.inst	0x00000000 ; undefined


#endif

